/*gXRWssrWJQWX2gQjDt8FbbTNRjyT6mYkz0VfTqh/hoaHS1IVXJjoZMhRwwUS9lzG*/
/*
 * @Author: xiahui 
 * @PageInfo: 生成付款申请
 * @Date: 2019-03-06 08:52:02 
 * @Last Modified by: xiahui
 * @Last Modified time: 2019-07-10 15:28:19
 */
import { ajax, cacheTools } from 'nc-lightapp-front';
import { AREA, FIELDS, URL } from '../../constance';
import { showWarningInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil';
import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil';

export default function(props) {
	let checkArr = props.editTable.getCheckedRows(AREA.listTableId);
	if (!checkArr || checkArr.length < 1) {
		showWarningInfo(null, getLangByResId(this, '4004PAYPLAN-000002')); /* 国际化处理： 请选择数据*/
		return;
	}

	let reqData = []; // 请求数据
	let pks = []; // 跳转时，传递的pk
	checkArr.map((row) => {
		let pk = row.data.values[FIELDS.pk_ct_payplan].value;
		reqData.push({
			id: pk,
			ts: row.data.values[FIELDS.ts].value
		});
		pks.push(pk);
	});

	ajax({
		url: URL.genpayreq,
		data: reqData,
		success: (res) => {
			if (res.success && res.data) {
				cacheTools.set('Z2TO36D1Pks', pks);
				props.openTo('/nccloud/resources/cmp/apply/apply/main/index.html#/card', {
					srcbilltype: 'Z2',
					pagecode: res.data[0].pagecode,
					appcode: res.data[0].appcode,
					status: 'add'
				});
			}
		}
	});
}

/*gXRWssrWJQWX2gQjDt8FbbTNRjyT6mYkz0VfTqh/hoaHS1IVXJjoZMhRwwUS9lzG*/